<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>路由传参</title>
    <script src="js/vue.js"></script>
    <script src="js/vue-router.js"></script>
</head>
<body>
    <template id="t1">
       <div>
           类型:{{$route.params.category}}<br>
           <h2>{{newsList[$route.params.category-1]}}</h2>
       </div>
    </template>
    <div id="app">
        <div>
            <ul>
                <li><router-link to="/news/1">今日头条</router-link></li>
                <li><router-link to="/news/2">体育新闻</router-link></li>
                <li><router-link to="/news/3">娱乐信息</router-link></li>
            </ul>
        </div>
        <div>
            <router-view></router-view>
        </div>
    </div>
</body>
</html>
<script>
    var vm=new Vue({
        el:'#app',
        router:new VueRouter({
            routes: [
                {
                    path:'/news/:category',
                    component:{
                        template:'#t1',
                        data() {
                            return {
                                newsList:[
                                    '今日头条信息',
                                    '体育新闻信息',
                                    '娱乐新闻信息'
                                ]
                            }
                        },
                    }
                }
            ]
        })
    });
</script>